#include "Solution.h"
#include <iostream>
#include <memory>
using namespace std;

int main()
{
	int m,n;
	cin>>m>>n;

	int *A = new int[m], *B = new int[n];
	
	for(int i=0;i<m;i++)
		cin>>A[i];
	for(int j=0;j<n;j++)
		cin>>B[j];

	Solution s;
	cout<<s.findMedianSortedArrays(A,m,B,n);
	cin.get();
	cin.get();
}